package com.isoft.dao;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.isoft.entity.AirportChange;
import com.isoft.entity.FlightLine;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface AirportChangedao extends BaseMapper<AirportChange> {
    @Select("SELECT * FROM AIRPORT.APUE where ISDELETE = 0")
    public List<AirportChange> getAll();
    //根据目的地查找

    public List<AirportChange> getByCons(String cnnm,String frcd);

    //变更审核
    @Update("update AIRPORT.APUE  SET ISPERMIT=1 WHERE ID = #{ID};")
    public int changePermit(Integer ID);
    //逻辑删
    @Update("UPDATE AIRPORT.APUE SET ISDELETE = 1 WHERE ID=#{id}")
    public int deleteChange(Integer id);

    @Insert("insert into AIRPORT.APUE(CODE,FRCD,APAT,CNNM,ENNM,AISO,APSN,ISPERMIT) values (#{code},#{frcd},#{apat},#{cnnm},#{ennm},#{aiso},#{apsn},#{ispermit})")
    public int addChange(AirportChange airportChange);
 /*   @Update("<script>" +
            "update AIRPORT.APUE" +
            "        <set> " +
            "            <if test=\"null != code\"> " +
            "               AIRPORT.APUE.CODE =#{code},                 " +
            "            </if> " +
            "            <if test=\"null != frcd\"> " +
            "               AIRPORT.APUE.FRCD =#{frcd},                 " +
            "            </if> " +
            "            <if test=\"null != apat\"> " +
            "               AIRPORT.APUE.APAT =#{apat},                 " +
            "            </if> " +
            "            <if test=\"null != cnnm\"> " +
            "               AIRPORT.APUE.CNNM =#{cnnm},                 " +
            "            </if> " +
            "            <if test=\"null != ennm\"> " +
            "               AIRPORT.APUE.ENNM=#{ennm},                 " +
            "            </if> " +
            "            <if test=\"null != aiso\"> " +
            "               AIRPORT.APUE.AISO =#{aiso},                 " +
            "            </if> " +
            "            <if test=\"null !=apsn\"> " +
            "                AIRPORT.APUE.APSN=#{apsn},  " +
            "            </if> " +
            "        </set> " +
            "        where AIRPORT.APUE.ID=#{id}"
            +"</script>")*/
    @Update("UPDATE APUE SET CODE=#{code},FRCD=#{frcd},APAT=#{apat},CNNM=#{cnnm},ENNM=#{ennm},AISO=#{aiso},APSN=#{apsn} where ID=#{id}")
    public int updateChange(AirportChange airportChange);

    @Select("SELECT * FROM AIRPORT.APUE where ISPERMIT = 0")
    public List<AirportChange> unPermit();
}
